package cn.licoy.wdog.core.controller;
/**
 * @Author Sunne
 * @Date 2018/8/27/02714:07
 * @Param emp-hospital
 * 高山仰止,景行行止.虽不能至,心向往之。
 **/

import cn.licoy.wdog.common.annotation.SysLogs;
import cn.licoy.wdog.core.entity.hospital.DetectionInfo;
import cn.licoy.wdog.core.entity.hospital2.Sheet;
import cn.licoy.wdog.core.service.hospital.DetectionInfoService;
import cn.licoy.wdog.core.service.hospital2.SheetService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.transform.Source;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 *——————————————————————————女神保佑，永无bug——————————————————————
 *
 *                    .::::.
 *                  .::::::::.
 *                 :::::::::::  FUCK YOU
 *             ..:::::::::::'
 *           '::::::::::::'
 *             .::::::::::
 *        '::::::::::::::..
 *             ..::::::::::::.
 *           ``::::::::::::::::
 *            ::::``:::::::::'        .:::.
 *           ::::'   ':::::'       .::::::::.
 *         .::::'      ::::     .:::::::'::::.
 *        .:::'       :::::  .:::::::::' ':::::.
 *       .::'        :::::.:::::::::'      ':::::.
 *      .::'         ::::::::::::::'         ``::::.
 *  ...:::           ::::::::::::'              ``::.
 * ```` ':.          ':::::::::'                  ::::..
 *                    '.:::::'                    ':'````..
 */

@RestController
@RequestMapping(value = {"/ST"})
@Api(tags = {"ST"})
public class ST {
    @Autowired
    private SheetService sheetService;
    @Autowired
    private DetectionInfoService detectionInfoService;

    @PostMapping(value = {"/sel"})
    @ApiOperation(value = "登录")
    private void sel(){
        List<Sheet> ls = sheetService.selectList(new EntityWrapper<>());

//        String res = simpleDateFormat.format(date);
        System.out.println(ls.size());
        for (int i=0;i<ls.size();i++){
            DetectionInfo detectionInfo = new DetectionInfo();
            detectionInfo.setCreateUserId(ls.get(i).getCreateUserId());
            detectionInfo.setCre(ls.get(i).getCre());
            detectionInfo.setDetectionDate(getDate(ls.get(i).getDetectionDate()));
            detectionInfo.setIsException(ls.get(i).getIsException());
            detectionInfo.setBil(ls.get(i).getBil());
            detectionInfo.setBld(ls.get(i).getBld());
            detectionInfo.setCa(ls.get(i).getCa());
            detectionInfo.setGender(ls.get(i).getGender());
            detectionInfo.setGlu(ls.get(i).getGlu());
            detectionInfo.setKet(ls.get(i).getKet());
            detectionInfo.setLeu(ls.get(i).getLeu());
            detectionInfo.setMa(ls.get(i).getMa());
            detectionInfo.setNit(ls.get(i).getNit());
            detectionInfo.setPh(ls.get(i).getPh());
            detectionInfo.setPro(ls.get(i).getPro());
            detectionInfo.setRegion(ls.get(i).getRegion());
            detectionInfo.setSerialNum(ls.get(i).getSerialNum());
            detectionInfo.setSg(ls.get(i).getSg());
            detectionInfo.setUbg(ls.get(i).getUbg());
            detectionInfo.setUsername(ls.get(i).getUsername());
            detectionInfo.setVc(ls.get(i).getVc());
            detectionInfo.setCreateDate(new Date());
            detectionInfo.setRemake("1");
            detectionInfo.setStatus(1);
            detectionInfoService.insert(detectionInfo);
        }
    }
    public Date getDate(String date){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long lt = new Long(date);
        Date dt = new Date(lt);
        return dt;
    }
}
